<?php
/**
 * DotHerbert
 *
 * @package    loader
 * @copyright  2009 extreme-programmers
 * @license    http://dotherbert.extreme-programmers.com/license   BSD License
 * @version    $Id:$
 */

namespace dotherbert\loader;
use dotherbert\core\stub;

require_once 'dotherbert/loader/AutoloaderInterface.php';
require_once 'dotherbert/core/stub/ControlStructureStub.php';

/**
 * Default autoloader
 *
 * Loads namespaced classes
 *
 * @package    loader
 * @author     Johannes Trink <johannes.trink@extreme-programmers.com>
 */
class DefaultAutoloader implements AutoloaderInterface
{
    /**
     * Autoload
     *
     * @param string $class
     * @return bool
     */
    public function autoload($class)
    {
        if (false === strpos($class, '\\')) {
            return false;
        }
        $file = str_replace('\\', '/', $class) . '.php';
        return stub\ControlStructureStub::getInstance()->includeFile($file);
    }
}